
#include <dlfcn.h>
#include <stdio.h>
#include "echo.h"


typedef void (*EchoFn)(const char*);

int main(int argc, char** argv)
{
	echo("Echoing from main exe -- static\n");

	void* handle = dlopen("liba_shared_lib.so", RTLD_LAZY);

	if (!handle)
	{
		printf("Failed to open lib: %s\n", dlerror());
		return -1;
	}

	EchoFn echoFn = (EchoFn)dlsym(handle, "doEcho");

	if (!echoFn)
	{
		printf("Failed to find doEcho in lib\n");
		return -2;
	}

	echoFn("Echoing from main exe -- shared\n");
	return 0;
}

